window.addEvent('domready',function(){

	$$('.socializer').addEvent('click',function(e){
		if(document.getElementById('containerx') == null){

		//ENABLE POPUP START
		//Popup for Firefox, buggy for ie7???
		var popit = true;  //true or false (true for popup, false for new window)
		 //dimensions of window
		var popheight = 500; 
		var popwidth = 700;
		var scrolls = 'yes';
		var resizes = 'yes';
		//ENABLE POPUP END


		// define container pos
		var top 	= this.getCoordinates().top.toInt();
		var height	= this.getCoordinates().height.toInt();
		var left	= this.getCoordinates().left.toInt();
		var pos 	= top+height+1;
		var div 	= new Element('div');
		
		div.setStyle('top',pos);
	    div.setStyle('left',left);
		div.addClass('soc_container');
		div.setAttribute('id','containerx');
		div.injectInside(document.body);
				
		// close button
		var closeme = new Element('img');
		closeme.src="social/images/close_trans.png";
		closeme.setAttribute('id','close');
		closeme.injectInside(div);
		closeme.addEvent('click',function(){
			div.dispose();
		})
	
		var title= this.title;
		var url  = this.alt;
	
		var name = new Element('h2');
		name.innerHTML = 'Share this page!';
		name.injectInside(div);
		
		var left = new Element('div');
		left.addClass('soc_left');
		left.injectInside(div);

		//Links on LEFT SIDE of container Links on LEFT SIDE of container Links on LEFT SIDE of container Links on LEFT SIDE of container 
		//Links on LEFT SIDE of container Links on LEFT SIDE of container Links on LEFT SIDE of container Links on LEFT SIDE of container 
	
		//START bookmark it - ADD TO FAVOURITES
		var book = new Element('img');
		book.alt = 'bookmark';
		book.src = 'social/images/favorites.png';
		book.injectInside(left);

        var myBOOKLink = new Element('a');
		myBOOKLink.title = title;
		myBOOKLink.innerHTML = 'bookmark';
		if (window.sidebar || (window.opera && window.print)){ // firefox
				myBOOKLink.href  = encodeURIComponent(url);
			    myBOOKLink.setAttribute('rel','sidebar');
		}else{// ie
                myBOOKLink.href = 'javascript:window.external.AddFavorite(this.location.href,this.document.title)'; 
		}
		myBOOKLink.injectInside(left);        


		// del.icio.us
		var img = new Element('img');
		img.alt = 'send to del.icio.us';
		img.src = 'social/images/delicious.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://del.icio.us/post?url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to del.icio.us';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'del.icio.us';
		myLink.injectInside(left);

        // mySpace
		var img = new Element('img');
		img.alt = 'send to MySpace';
		img.src = 'social/images/myspace.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.myspace.com/Modules/PostTo/Pages/?t='+title+'&c='+encodeURIComponent(url);
		myLink.title = 'send to MySpace';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'MySpace';
		myLink.injectInside(left);

		// furl.net
		var img = new Element('img');
		img.alt = 'send to furl';
		img.src = 'social/images/furl.gif';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://furl.net/storeIt.jsp?t='+title+'&u='+encodeURIComponent(url);
		myLink.title = 'send to furl';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'furl';
		myLink.injectInside(left);

		// stumpleupon.com
		var img = new Element('img');
		img.alt = 'send to stumbleupon';
		img.src = 'social/images/su.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.stumbleupon.com/refer.php?url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to stumbleupon';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'stumbleupon';
		myLink.injectInside(left);

		// newsvine.com
		var img = new Element('img');
		img.alt = 'send to newsvine.com';
		img.src = 'social/images/newsvine.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.newsvine.com/_wine/save?u='+encodeURIComponent(url)+'&h='+title;
		myLink.title = 'send to newsvine';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'newsvine';
		myLink.injectInside(left);

		// technorati.com
		var img = new Element('img');
		img.alt = 'send to technorati.com';
		img.src = 'social/images/technorati.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.technorati.com/faves?add='+encodeURIComponent(url);
		myLink.title = 'send to technorati';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'technorati';
		myLink.injectInside(left);

        // ask.com
		//var img = new Element('img');
		//img.alt = 'send to ask.com';
		//img.src = 'social/images/ask.png';
		//img.injectInside(left);
		
		//var myLink = new Element('a');
		//myLink.href  = 'http://mystuff.ask.com/mysearch/QuickWebSave?v=1.2&t=webpages&title='+title+'&url='+encodeURIComponent(url);
		//myLink.title = 'send to ask';
		//myLink.target = 'myWindow';
        //myLink.rel = 'nofollow';
		//myLink.innerHTML = 'ask';
		//myLink.injectInside(left);

     	// feedmelinks.com
		var img = new Element('img');
		img.alt = 'send to feedmelinks.com';
		img.src = 'social/images/feedmelinks.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://feedmelinks.com/categorize?from=toolbar&op=submit&name='+title+'&url='+encodeURIComponent(url)
		myLink.title = 'send to feedmelinks';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'feedmelinks';
		myLink.injectInside(left);

		// slashdot.org
		var img = new Element('img');
		img.alt = 'send to slashdot.org';
		img.src = 'social/images/slashdot.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://slashdot.org/bookmark.pl?title='+title+'&url='+encodeURIComponent(url);
		myLink.title = 'send to slashdot';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'slashdot';
		myLink.injectInside(left);

        // mixx.com
		var img = new Element('img');
		img.alt = 'send to mixx.com';
		img.src = 'social/images/mixx.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.mixx.com/submit?page_url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to mixx';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'mixx';
		myLink.injectInside(left);

		// simpy.com
		var img = new Element('img');
		img.alt = 'send to simpy.com';
		img.src = 'social/images/simpy.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://simpy.com/simpy/LinkAdd.do?note='+title+'&href='+encodeURIComponent(url);
		myLink.title = 'send to simpy';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'simpy';
		myLink.injectInside(left);

        // diigo.com
		var img = new Element('img');
		img.alt = 'send to diigo.com';
		img.src = 'social/images/diigo.gif';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.diigo.com/post?url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to diigo';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'diigo';
		myLink.injectInside(left);

		// spurl.net
		var img = new Element('img');
		img.alt = 'send to spurl.net';
		img.src = 'social/images/spurl.png';
		img.injectInside(left);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.spurl.net/spurl.php?url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to spurl';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'spurl';
		myLink.injectInside(left);
		

		// RIGHT SIDE OF CONTAINER RIGHT SIDE OF CONTAINER 	RIGHT SIDE OF CONTAINER RIGHT SIDE OF CONTAINER	RIGHT SIDE OF CONTAINER 		
		// RIGHT SIDE OF CONTAINER RIGHT SIDE OF CONTAINER 	RIGHT SIDE OF CONTAINER RIGHT SIDE OF CONTAINER	RIGHT SIDE OF CONTAINER 		
		
		var right = new Element('div');
		right.addClass('soc_left');
		right.injectInside(div);

		// EMAIL IT - START
		var img = new Element('img');
		img.alt = 'send to multiply.com';
		img.src = 'social/images/email.png';
		img.injectInside(right);
		
        var myBOOKLink = new Element('a');
		myBOOKLink.title = title;
		myBOOKLink.innerHTML = 'Email...';
		myBOOKLink.addEvent('click',function(e){
			e.stop();
			$$('.soc_left').set({opacity:1}).fade(0);
			$$('.soc_left').dispose();

			var con = new Element('div');
			con.addClass('soc_send_friend');
			con.injectInside(div);
			
			var ptag = new Element('div');
			ptag.addClass('email_mess');
			ptag.innerHTML = 'Email this page to a friend';
			ptag.injectInside(con);
			ptag.setStyle('color','#000');
			
			var form = new Element('form');
			form.setAttribute('name','friendform');
			form.setAttribute('id','friendform');

			var label_1 = new Element('label');
			label_1.innerHTML = 'From Email: ';
					
			var inp = new Element('input');
			inp.setAttribute('type','text');
			inp.setAttribute('id','email_friend');

			var label_2 = new Element('label');
			label_2.innerHTML = '<br/>&nbsp;&nbsp;&nbsp;&nbsp;To Email: ';
					
			var inp2 = new Element('input');
			inp2.setAttribute('type','text');
			inp2.setAttribute('id','email_friend2');
			
			var sendme = new Element('input');
			sendme.setAttribute('type','submit');
			sendme.setAttribute('value',"Send");
			sendme.addClass('sendit');
			
			form.injectInside(con);
			label_1.injectInside(form);
			inp.injectInside(form);	
			label_2.injectInside(form);
			inp2.injectInside(form);	
			sendme.injectAfter(inp2);
			
			$('friendform').addEvent('submit',function(el){
					el.stop();
					con.empty();
					$(con).innerHTML = '<p align="center">Sending email, please wait...</p>';
					$(con).addClass('wait');
					var input = inp.value;  //From Email
					var input2 = inp2.value;  //To Email
					
					new Request.HTML({ url: 'social/send_to_friend.php', data:'email='+input2+'&fromemail='+input+'&title='+title+'&url='+encodeURIComponent(url), method:'get', update: $(con), onComplete:function() { $(con).removeClass('wait') } }).send();	
					return false;
			})
			
			con.set({opacity:0}).fade(1);
		});
		myBOOKLink.injectInside(right); 
		// EMAIL IT - END
		
		// google.com
		var img = new Element('img');
		img.alt = 'send to google';
		img.src = 'social/images/goog.gif';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.google.com/bookmarks/mark?op=edit&bkmk='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to google';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'google';
		myLink.injectInside(right);

		// digg.com
		var img = new Element('img');
		img.alt = 'send to digg';
		img.src = 'social/images/digg.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://digg.com/submit?phase=2&url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to digg';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'digg';
		myLink.injectInside(right);

		// facebook.com
		var img = new Element('img');
		img.alt = 'send to facebook';
		img.src = 'social/images/facebook.gif';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+title;
		myLink.title = 'send to facebook';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'facebook';
		myLink.injectInside(right);

		// yahoo.com
		var img = new Element('img');
		img.alt = 'send to yahoo.com';
		img.src = 'social/images/yahoo-myweb.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(url)+'&t='+title
		myLink.title = 'send to yahoo';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'yahoo';
		myLink.injectInside(right);

		// reddit.com
		var img = new Element('img');
		img.alt = 'send to reddit.com';
		img.src = 'social/images/reddit.gif';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://reddit.com/submit?url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to reddit';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'reddit';
		myLink.injectInside(right);

     	// twitthis.com
		var img = new Element('img');
		img.alt = 'send to Twitter';
		img.src = 'social/images/twitter.gif';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://twitthis.com/twit?url='+encodeURIComponent(url);
		myLink.title = 'send to Twitter';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'Twitter';
		myLink.injectInside(right);

    	// fark.com
		var img = new Element('img');
		img.alt = 'send to Fark';
		img.src = 'social/images/fark.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://cgi.fark.com/cgi/fark/edit.pl?new_url='+encodeURIComponent(url)+'&new_comment='+title;
		myLink.title = 'send to Fark';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'Fark';
		myLink.injectInside(right);

    	// blogmarks.net
		var img = new Element('img');
		img.alt = 'send to Blogmarks';
		img.src = 'social/images/blogmarks.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://blogmarks.net/my/new.php?mini=1&title='+title+'&url='+encodeURIComponent(url);
		myLink.title = 'send to Blogmarks';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'Blogmarks';
		myLink.injectInside(right);

    	// linkagogo.com
		var img = new Element('img');
		img.alt = 'send to linkagogo';
		img.src = 'social/images/linkagogo.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.linkagogo.com/go/AddNoPopup?title='+title+'&url='+encodeURIComponent(url);
		myLink.title = 'send to linkagogo';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'linkagogo';
		myLink.injectInside(right);


        // backflip.com
		var img = new Element('img');
		img.alt = 'send to backflip.com';
		img.src = 'social/images/backflip.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://www.backflip.com/add_page_pop.ihtml?url='+encodeURIComponent(url)+'&title='+title;
		myLink.title = 'send to backflip';
		myLink.target = 'myWindow';
		myLink.innerHTML = 'backflip';
		myLink.injectInside(right);

				
		// netvouz.com
		var img = new Element('img');
		img.alt = 'send to netvouz.com';
		img.src = 'social/images/netvouz.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://netvouz.com/action/submitBookmark?url='+encodeURIComponent(url)+'&title='+title+'&popup=no'
		myLink.title = 'send to netvouz';
        myLink.target = 'myWindow';
		myLink.innerHTML = 'netvouz';
		myLink.injectInside(right);


		// multiply.com
		var img = new Element('img');
		img.alt = 'send to multiply.com';
		img.src = 'social/images/multiply.png';
		img.injectInside(right);
		
		var myLink = new Element('a');
		myLink.href  = 'http://multiply.com/?xurl='+encodeURIComponent(url)+'&t='+title;
		myLink.title = 'send to multiply';
        myLink.target = 'myWindow';
		myLink.innerHTML = 'multiply';
		myLink.injectInside(right);
		
		// fade in
		$('containerx').set({opacity:0}).fade(1);
		$$('.soc_left').setStyle('visibility','visible');

		$$('.soc_left a').addEvent('click',function(e){
			 if(this.target == 'myWindow' && popit){	
				 e = new Event(e).stop();
				 window.open(this.href, 'myWindow', 'width='+popwidth+',height='+popheight+',scrollbars='+scrolls+',resizable='+ resizes+',menubar=yes,toolbar=yes').focus();
				 return false;
			 }
		});

	  }else{
		$('containerx').dispose();
		}
	})
});



